package com.kunzai.threadafety.threadcom;

public class TrainBook implements Runnable{

    private int count=10;
   private final static Object LOCK = new Object();

    @Override
    public void run() {
        while (true){
            synchronized (TrainBook.LOCK) {
                try {
                    //模拟售票耗时的诗句
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (count==0){
                    break;
                }

                System.out.println(Thread.currentThread().getName()+count--);

            }
        }
    }
}
